package com.service.base.generator;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@Controller
@EnableWebMvc
@ServletComponentScan
@SpringBootApplication
public class GeneratorApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext run = SpringApplication.run(GeneratorApplication.class, args);
        ConfigurableEnvironment environment = run.getEnvironment();

        log.info("\n======================================================\n\t"+
                        "Application is running !!! \n\t"+
                        "Access URLs:\t http://{}:{}\n"+
                        "======================================================",
                InetAddress.getLocalHost().getHostAddress(),
                environment.getProperty("server.port")
        );
    }
    @RequestMapping("/")
    public String home(){
        return "redirect:/index";
    }

}
